# Packages ----------------------------------------------------------------
library(lavaan)

# Load Data ----------------------------------------------------------------
source("./main/study3_cleaning.R")

# Models ------------------------------------------------------------------
# * NFC-Populism -------------------------------------------------------------
m <- '
nfc =~ nfc_teardown
+ nfc_needchaos
+ nfc_destroy
+ nfc_disastFun 
+ nfc_disastRebuild
+ nfc_burnsociety
+ nfc_burninstits
+ nfc_clearrules # rev here and down
+ nfc_upholdorder
+ nfc_chaosupset # NEW
+ nfc_respectproduct # NEW
+ nfc_workinside # NEW
+ nfc_protectinstits # NEW
+ nfc_greatthings # NEW

pop =~ pop_fewints
+ pop_crooked
+ pop_nomethink
+ pop_polsimprove # rev here down
+ pop_yesmethink
+ pop_benefitall

# error variances (content similarities)
pop_nomethink ~~ pop_yesmethink
'
m_nfcPop <- cfa(m, mt)
summary(m_nfcPop, fit.measures = T, standardized = T)

m_method <- '
# substantive
nfc =~ nfc_teardown
+ nfc_needchaos
+ nfc_destroy
+ nfc_disastFun 
+ nfc_disastRebuild
+ nfc_burnsociety
+ nfc_burninstits
+ nfc_clearrules # rev here and down
+ nfc_upholdorder
+ nfc_chaosupset # NEW
+ nfc_respectproduct # NEW
+ nfc_workinside # NEW
+ nfc_protectinstits # NEW
+ nfc_greatthings # NEW

pop =~ pop_fewints
+ pop_crooked
+ pop_nomethink
+ pop_polsimprove # rev here down
+ pop_yesmethink
+ pop_benefitall

# method
method =~ nfc_teardown
+ 1*nfc_needchaos
+ 1*nfc_destroy
+ 1*nfc_disastFun 
+ 1*nfc_disastRebuild
+ 1*nfc_burnsociety
+ 1*nfc_burninstits
+ -1*nfc_clearrules # rev here and down
+ -1*nfc_upholdorder
+ -1*nfc_chaosupset # NEW
+ -1*nfc_respectproduct # NEW
+ -1*nfc_workinside # NEW
+ -1*nfc_protectinstits # NEW
+ -1*nfc_greatthings # NEW
+ 1*pop_fewints
+ 1*pop_crooked
+ 1*pop_nomethink
+ -1*pop_polsimprove # rev here down
+ -1*pop_yesmethink
+ -1*pop_benefitall

# error variances (content similarities)
pop_nomethink ~~ pop_yesmethink

# covariances
method ~~ 0*nfc + 0*pop
'
m_nfcPop_method <- cfa(m_method, mt)
summary(m_nfcPop_method, fit.measures = T, standardized = T) 

# residuals(m_nfcPop_method, type = "standardized")
# modindices(m_nfcPop_method, minimum.value = 10, sort = T)

# store correlations
ests_nfcPop_nomethod <- standardizedSolution(m_nfcPop)
ests_nfcPop_method <- standardizedSolution(m_nfcPop_method)
ests_nfcPop <- rbind(subset(ests_nfcPop_nomethod, op == "~~" & lhs == "nfc" & rhs == "pop", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                         subset(ests_nfcPop_method, op == "~~" & lhs == "nfc" & rhs == "pop", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_nfcPop$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_nfcPop_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_nfcPop_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_nfcPop <- rbind(load_nomethod, load_method)
loadings_nfcPop$model <- c(rep("No Method", nrow(load_nomethod)),
                               rep("Method", nrow(load_nomethod)))
loadings_nfcPop$var <- "nfcPop"

# store error variance
p <- parameterestimates(m_nfcPop_method)
m_var_nfcPop <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# * NFC-Violence -------------------------------------------------------------
m <- '
nfc =~ nfc_teardown
+ nfc_needchaos
+ nfc_destroy
+ nfc_disastFun 
+ nfc_disastRebuild
+ nfc_burnsociety
+ nfc_burninstits
+ nfc_clearrules # rev here and down
+ nfc_upholdorder
+ nfc_chaosupset # NEW
+ nfc_respectproduct # NEW
+ nfc_workinside # NEW
+ nfc_protectinstits # NEW
+ nfc_greatthings # NEW

viol =~ viol_threatpols
+ viol_bricks
+ viol_stopbadgovt
+ viol_bullets
+ viol_noviol # rev here down
+ viol_nonviolprot # NEW
+ viol_violunaccept # NEW
+ viol_notit4tat # NEW
'
m_nfcviol <- cfa(m, mt)
summary(m_nfcviol, fit.measures = T, standardized = T)

m_method <- '
# substantive
nfc =~ nfc_teardown
+ nfc_needchaos
+ nfc_destroy
+ nfc_disastFun 
+ nfc_disastRebuild
+ nfc_burnsociety
+ nfc_burninstits
+ nfc_clearrules # rev here and down
+ nfc_upholdorder
+ nfc_chaosupset # NEW
+ nfc_respectproduct # NEW
+ nfc_workinside # NEW
+ nfc_protectinstits # NEW
+ nfc_greatthings # NEW

viol =~ viol_threatpols
+ viol_bricks
+ viol_stopbadgovt
+ viol_bullets
+ viol_noviol # rev here down
+ viol_nonviolprot # NEW
+ viol_violunaccept # NEW
+ viol_notit4tat # NEW

# method
method =~ nfc_teardown
+ 1*nfc_needchaos
+ 1*nfc_destroy
+ 1*nfc_disastFun 
+ 1*nfc_disastRebuild
+ 1*nfc_burnsociety
+ 1*nfc_burninstits
+ -1*nfc_clearrules # rev here and down
+ -1*nfc_upholdorder
+ -1*nfc_chaosupset # NEW
+ -1*nfc_respectproduct # NEW
+ -1*nfc_workinside # NEW
+ -1*nfc_protectinstits # NEW
+ -1*nfc_greatthings # NEW
+ 1*viol_threatpols
+ 1*viol_bricks
+ 1*viol_stopbadgovt
+ 1*viol_bullets
+ -1*viol_noviol # rev here down
+ -1*viol_nonviolprot # NEW
+ -1*viol_violunaccept # NEW
+ -1*viol_notit4tat # NEW

# covariances
method ~~ 0*nfc + 0*viol
'
m_nfcviol_method <- cfa(m_method, mt)
summary(m_nfcviol_method, fit.measures = T, standardized = T) 

# residuals(m_nfcviol_method, type = "standardized")
# modindices(m_nfcviol_method, minimum.value = 10, sort = T)

# store correlations
ests_nfcviol_nomethod <- standardizedSolution(m_nfcviol)
ests_nfcviol_method <- standardizedSolution(m_nfcviol_method)
ests_nfcviol <- rbind(subset(ests_nfcviol_nomethod, op == "~~" & lhs == "nfc" & rhs == "viol", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                     subset(ests_nfcviol_method, op == "~~" & lhs == "nfc" & rhs == "viol", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_nfcviol$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_nfcviol_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_nfcviol_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_nfcviol <- rbind(load_nomethod, load_method)
loadings_nfcviol$model <- c(rep("No Method", nrow(load_nomethod)),
                           rep("Method", nrow(load_nomethod)))
loadings_nfcviol$var <- "nfcviol"

# store error variance
p <- parameterestimates(m_nfcviol_method)
m_var_nfcviol <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# * NFC-Conspiracy -------------------------------------------------------------
m <- '
nfc =~ nfc_teardown
+ nfc_needchaos
+ nfc_destroy
+ nfc_disastFun 
+ nfc_disastRebuild
+ nfc_burnsociety
+ nfc_burninstits
+ nfc_clearrules # rev here and down
+ nfc_upholdorder
+ nfc_chaosupset # NEW
+ nfc_respectproduct # NEW
+ nfc_workinside # NEW
+ nfc_protectinstits # NEW
+ nfc_greatthings # NEW

consp =~ consp_plots
+ consp_fewppl
+ consp_dkrun
+ consp_wars
+ consp_schoolexps # NEW, rev here down
+ consp_complex # NEW
+ consp_US # NEW

'
m_nfcconsp <- cfa(m, mt)
summary(m_nfcconsp, fit.measures = T, standardized = T)

m_method <- '
# substantive
nfc =~ nfc_teardown
+ nfc_needchaos
+ nfc_destroy
+ nfc_disastFun 
+ nfc_disastRebuild
+ nfc_burnsociety
+ nfc_burninstits
+ nfc_clearrules # rev here and down
+ nfc_upholdorder
+ nfc_chaosupset # NEW
+ nfc_respectproduct # NEW
+ nfc_workinside # NEW
+ nfc_protectinstits # NEW
+ nfc_greatthings # NEW

consp =~ consp_plots
+ consp_fewppl
+ consp_dkrun
+ consp_wars
+ consp_schoolexps # NEW, rev here down
+ consp_complex # NEW
+ consp_US # NEW


# method
method =~ nfc_teardown
+ 1*nfc_needchaos
+ 1*nfc_destroy
+ 1*nfc_disastFun 
+ 1*nfc_disastRebuild
+ 1*nfc_burnsociety
+ 1*nfc_burninstits
+ -1*nfc_clearrules # rev here and down
+ -1*nfc_upholdorder
+ -1*nfc_chaosupset # NEW
+ -1*nfc_respectproduct # NEW
+ -1*nfc_workinside # NEW
+ -1*nfc_protectinstits # NEW
+ -1*nfc_greatthings # NEW
+ 1*consp_plots
+ 1*consp_fewppl
+ 1*consp_dkrun
+ 1*consp_wars
+ -1*consp_schoolexps # NEW, rev here down
+ -1*consp_complex # NEW
+ -1*consp_US # NEW

# covariances
method ~~ 0*nfc + 0*consp
'
m_nfcconsp_method <- cfa(m_method, mt)
summary(m_nfcconsp_method, fit.measures = T, standardized = T) 

# residuals(m_nfcconsp_method, type = "standardized")
# modindices(m_nfcconsp_method, minimum.value = 10, sort = T)

# store correlations
ests_nfcconsp_nomethod <- standardizedSolution(m_nfcconsp)
ests_nfcconsp_method <- standardizedSolution(m_nfcconsp_method)
ests_nfcconsp <- rbind(subset(ests_nfcconsp_nomethod, op == "~~" & lhs == "nfc" & rhs == "consp", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                     subset(ests_nfcconsp_method, op == "~~" & lhs == "nfc" & rhs == "consp", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_nfcconsp$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_nfcconsp_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_nfcconsp_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_nfcconsp <- rbind(load_nomethod, load_method)
loadings_nfcconsp$model <- c(rep("No Method", nrow(load_nomethod)),
                           rep("Method", nrow(load_nomethod)))
loadings_nfcconsp$var <- "nfcconsp"

# store error variance
p <- parameterestimates(m_nfcconsp_method)
m_var_nfcconsp <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# * NFC-RR -------------------------------------------------------------
m <- '
nfc =~ nfc_teardown
+ nfc_needchaos
+ nfc_destroy
+ nfc_disastFun 
+ nfc_disastRebuild
+ nfc_burnsociety
+ nfc_burninstits
+ nfc_clearrules # rev here and down
+ nfc_upholdorder
+ nfc_chaosupset # NEW
+ nfc_respectproduct # NEW
+ nfc_workinside # NEW
+ nfc_protectinstits # NEW
+ nfc_greatthings # NEW

rr =~ rr_specfavr
+ rr_thard
+ rr_pdisc
+ rr_dless

# error variances (content similarities)
rr_thard ~~ rr_specfavr
'
m_nfcrr <- cfa(m, mt)
summary(m_nfcrr, fit.measures = T, standardized = T)

m_method <- '
# substantive
nfc =~ nfc_teardown
+ nfc_needchaos
+ nfc_destroy
+ nfc_disastFun 
+ nfc_disastRebuild
+ nfc_burnsociety
+ nfc_burninstits
+ nfc_clearrules # rev here and down
+ nfc_upholdorder
+ nfc_chaosupset # NEW
+ nfc_respectproduct # NEW
+ nfc_workinside # NEW
+ nfc_protectinstits # NEW
+ nfc_greatthings # NEW

rr =~ rr_specfavr
+ rr_thard
+ rr_pdisc
+ rr_dless

# error variances (content similarities)
rr_thard ~~ rr_specfavr

# method
method =~ nfc_teardown
+ 1*nfc_needchaos
+ 1*nfc_destroy
+ 1*nfc_disastFun 
+ 1*nfc_disastRebuild
+ 1*nfc_burnsociety
+ 1*nfc_burninstits
+ -1*nfc_clearrules # rev here and down
+ -1*nfc_upholdorder
+ -1*nfc_chaosupset # NEW
+ -1*nfc_respectproduct # NEW
+ -1*nfc_workinside # NEW
+ -1*nfc_protectinstits # NEW
+ -1*nfc_greatthings # NEW
+ 1*rr_specfavr
+ 1*rr_thard
+ -1*rr_pdisc
+ -1*rr_dless

# covariances
method ~~ 0*nfc + 0*rr
'
m_nfcrr_method <- cfa(m_method, mt)
summary(m_nfcrr_method, fit.measures = T, standardized = T) 

# residuals(m_nfcrr_method, type = "standardized")
# modindices(m_nfcrr_method, minimum.value = 10, sort = T)

# store correlations
ests_nfcrr_nomethod <- standardizedSolution(m_nfcrr)
ests_nfcrr_method <- standardizedSolution(m_nfcrr_method)
ests_nfcrr <- rbind(subset(ests_nfcrr_nomethod, op == "~~" & lhs == "nfc" & rhs == "rr", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                     subset(ests_nfcrr_method, op == "~~" & lhs == "nfc" & rhs == "rr", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_nfcrr$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_nfcrr_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_nfcrr_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_nfcrr <- rbind(load_nomethod, load_method)
loadings_nfcrr$model <- c(rep("No Method", nrow(load_nomethod)),
                           rep("Method", nrow(load_nomethod)))
loadings_nfcrr$var <- "nfcrr"

# store error variance
p <- parameterestimates(m_nfcrr_method)
m_var_nfcrr <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# * NFC-HS -------------------------------------------------------------
m <- '
nfc =~ nfc_teardown
+ nfc_needchaos
+ nfc_destroy
+ nfc_disastFun 
+ nfc_disastRebuild
+ nfc_burnsociety
+ nfc_burninstits
+ nfc_clearrules # rev here and down
+ nfc_upholdorder
+ nfc_chaosupset # NEW
+ nfc_respectproduct # NEW
+ nfc_workinside # NEW
+ nfc_protectinstits # NEW
+ nfc_greatthings # NEW

hs =~ hs_control
+ hs_exaggerate
+ hs_leash
+ hs_reasonable
+ hs_feministpower
+ hs_fewwomen

# error variances (content similarities)
hs_reasonable ~~ hs_feministpower
'
m_nfchs <- cfa(m, mt)
summary(m_nfchs, fit.measures = T, standardized = T)

m_method <- '
# substantive
nfc =~ nfc_teardown
+ nfc_needchaos
+ nfc_destroy
+ nfc_disastFun 
+ nfc_disastRebuild
+ nfc_burnsociety
+ nfc_burninstits
+ nfc_clearrules # rev here and down
+ nfc_upholdorder
+ nfc_chaosupset # NEW
+ nfc_respectproduct # NEW
+ nfc_workinside # NEW
+ nfc_protectinstits # NEW
+ nfc_greatthings # NEW

hs =~ hs_control
+ hs_exaggerate
+ hs_leash
+ hs_reasonable
+ hs_feministpower
+ hs_fewwomen

# method
method =~ nfc_teardown
+ 1*nfc_needchaos
+ 1*nfc_destroy
+ 1*nfc_disastFun 
+ 1*nfc_disastRebuild
+ 1*nfc_burnsociety
+ 1*nfc_burninstits
+ -1*nfc_clearrules # rev here and down
+ -1*nfc_upholdorder
+ -1*nfc_chaosupset # NEW
+ -1*nfc_respectproduct # NEW
+ -1*nfc_workinside # NEW
+ -1*nfc_protectinstits # NEW
+ -1*nfc_greatthings # NEW
+ 1*hs_control
+ 1*hs_exaggerate
+ 1*hs_leash
+ -1*hs_reasonable
+ -1*hs_feministpower
+ -1*hs_fewwomen


# error variances (content similarities)
hs_reasonable ~~ hs_feministpower

# covariances
method ~~ 0*nfc + 0*hs
'
m_nfchs_method <- cfa(m_method, mt)
summary(m_nfchs_method, fit.measures = T, standardized = T) 

# residuals(m_nfchs_method, type = "standardized")
# modindices(m_nfchs_method, minimum.value = 10, sort = T)

# store correlations
ests_nfchs_nomethod <- standardizedSolution(m_nfchs)
ests_nfchs_method <- standardizedSolution(m_nfchs_method)
ests_nfchs <- rbind(subset(ests_nfchs_nomethod, op == "~~" & lhs == "nfc" & rhs == "hs", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                     subset(ests_nfchs_method, op == "~~" & lhs == "nfc" & rhs == "hs", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_nfchs$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_nfchs_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_nfchs_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_nfchs <- rbind(load_nomethod, load_method)
loadings_nfchs$model <- c(rep("No Method", nrow(load_nomethod)),
                           rep("Method", nrow(load_nomethod)))
loadings_nfchs$var <- "nfchs"

# store error variance
p <- parameterestimates(m_nfchs_method)
m_var_nfchs <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# * Populism-Violence -------------------------------------------------------------
m <- '
pop =~ pop_fewints
+ pop_crooked
+ pop_nomethink
+ pop_polsimprove # rev here down
+ pop_yesmethink
+ pop_benefitall

# error variances (content similarities)
pop_nomethink ~~ pop_yesmethink

viol =~ viol_threatpols
+ viol_bricks
+ viol_stopbadgovt
+ viol_bullets
+ viol_noviol # rev here down
+ viol_nonviolprot # NEW
+ viol_violunaccept # NEW
+ viol_notit4tat # NEW
'
m_popviol <- cfa(m, mt)
summary(m_popviol, fit.measures = T, standardized = T)

m_method <- '
# substantive
pop =~ pop_fewints
+ pop_crooked
+ pop_nomethink
+ pop_polsimprove # rev here down
+ pop_yesmethink
+ pop_benefitall


viol =~ viol_threatpols
+ viol_bricks
+ viol_stopbadgovt
+ viol_bullets
+ viol_noviol # rev here down
+ viol_nonviolprot # NEW
+ viol_violunaccept # NEW
+ viol_notit4tat # NEW

# method
method =~ pop_fewints
+ 1*pop_crooked
+ 1*pop_nomethink
+ -1*pop_polsimprove # rev here down
+ -1*pop_yesmethink
+ -1*pop_benefitall
+ 1*viol_threatpols
+ 1*viol_bricks
+ 1*viol_stopbadgovt
+ 1*viol_bullets
+ -1*viol_noviol # rev here down
+ -1*viol_nonviolprot # NEW
+ -1*viol_violunaccept # NEW
+ -1*viol_notit4tat # NEW

# error variances (content similarities)
pop_nomethink ~~ pop_yesmethink

# covariances
method ~~ 0*pop + 0*viol
'
m_popviol_method <- cfa(m_method, mt)
summary(m_popviol_method, fit.measures = T, standardized = T) 

# residuals(m_popviol_method, type = "standardized")
# modindices(m_popviol_method, minimum.value = 10, sort = T)

# store correlations
ests_popviol_nomethod <- standardizedSolution(m_popviol)
ests_popviol_method <- standardizedSolution(m_popviol_method)
ests_popviol <- rbind(subset(ests_popviol_nomethod, op == "~~" & lhs == "pop" & rhs == "viol", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                      subset(ests_popviol_method, op == "~~" & lhs == "pop" & rhs == "viol", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_popviol$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_popviol_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_popviol_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_popviol <- rbind(load_nomethod, load_method)
loadings_popviol$model <- c(rep("No Method", nrow(load_nomethod)),
                            rep("Method", nrow(load_nomethod)))
loadings_popviol$var <- "popviol"

# store error variance
p <- parameterestimates(m_popviol_method)
m_var_popviol <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# * Populism-Conspiracy -------------------------------------------------------------
m <- '
pop =~ pop_fewints
+ pop_crooked
+ pop_nomethink
+ pop_polsimprove # rev here down
+ pop_yesmethink
+ pop_benefitall

# error variances (content similarities)
pop_nomethink ~~ pop_yesmethink

consp =~ consp_plots
+ consp_fewppl
+ consp_dkrun
+ consp_wars
+ consp_schoolexps # NEW, rev here down
+ consp_complex # NEW
+ consp_US # NEW
'
m_popconsp <- cfa(m, mt)
summary(m_popconsp, fit.measures = T, standardized = T)

m_method <- '
# substantive
pop =~ pop_fewints
+ pop_crooked
+ pop_nomethink
+ pop_polsimprove # rev here down
+ pop_yesmethink
+ pop_benefitall


consp =~ consp_plots
+ consp_fewppl
+ consp_dkrun
+ consp_wars
+ consp_schoolexps # NEW, rev here down
+ consp_complex # NEW
+ consp_US # NEW

# method
method =~ pop_fewints
+ 1*pop_crooked
+ 1*pop_nomethink
+ -1*pop_polsimprove # rev here down
+ -1*pop_yesmethink
+ -1*pop_benefitall
+ 1*consp_plots
+ 1*consp_fewppl
+ 1*consp_dkrun
+ 1*consp_wars
+ -1*consp_schoolexps # NEW, rev here down
+ -1*consp_complex # NEW
+ -1*consp_US # NEW

# error variances (content similarities)
pop_nomethink ~~ pop_yesmethink

# covariances
method ~~ 0*pop + 0*consp
'
m_popconsp_method <- cfa(m_method, mt)
summary(m_popconsp_method, fit.measures = T, standardized = T) 

# residuals(m_popconsp_method, type = "standardized")
# modindices(m_popconsp_method, minimum.value = 10, sort = T)

# store correlations
ests_popconsp_nomethod <- standardizedSolution(m_popconsp)
ests_popconsp_method <- standardizedSolution(m_popconsp_method)
ests_popconsp <- rbind(subset(ests_popconsp_nomethod, op == "~~" & lhs == "pop" & rhs == "consp", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                      subset(ests_popconsp_method, op == "~~" & lhs == "pop" & rhs == "consp", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_popconsp$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_popconsp_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_popconsp_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_popconsp <- rbind(load_nomethod, load_method)
loadings_popconsp$model <- c(rep("No Method", nrow(load_nomethod)),
                            rep("Method", nrow(load_nomethod)))
loadings_popconsp$var <- "popconsp"

# store error variance
p <- parameterestimates(m_popconsp_method)
m_var_popconsp <- p$est[which(p$lhs == "method" & p$rhs == "method")]




# * Populism-RR -------------------------------------------------------------
m <- '
pop =~ pop_fewints
+ pop_crooked
+ pop_nomethink
+ pop_polsimprove # rev here down
+ pop_yesmethink
+ pop_benefitall

rr =~ rr_specfavr
+ rr_thard
+ rr_pdisc
+ rr_dless

# error variances (content similarities)
rr_thard ~~ rr_specfavr
pop_nomethink ~~ pop_yesmethink
'
m_poprr <- cfa(m, mt)
summary(m_poprr, fit.measures = T, standardized = T)

m_method <- '
# substantive
pop =~ pop_fewints
+ pop_crooked
+ pop_nomethink
+ pop_polsimprove # rev here down
+ pop_yesmethink
+ pop_benefitall


rr =~ rr_specfavr
+ rr_thard
+ rr_pdisc
+ rr_dless

# method
method =~ pop_fewints
+ 1*pop_crooked
+ 1*pop_nomethink
+ -1*pop_polsimprove # rev here down
+ -1*pop_yesmethink
+ -1*pop_benefitall
+ 1*rr_specfavr
+ 1*rr_thard
+ -1*rr_pdisc
+ -1*rr_dless

# error variances (content similarities)
rr_thard ~~ rr_specfavr
pop_nomethink ~~ pop_yesmethink

# covariances
method ~~ 0*pop + 0*rr
'
m_poprr_method <- cfa(m_method, mt)
summary(m_poprr_method, fit.measures = T, standardized = T) 

# residuals(m_poprr_method, type = "standardized")
# modindices(m_poprr_method, minimum.value = 10, sort = T)

# store correlations
ests_poprr_nomethod <- standardizedSolution(m_poprr)
ests_poprr_method <- standardizedSolution(m_poprr_method)
ests_poprr <- rbind(subset(ests_poprr_nomethod, op == "~~" & lhs == "pop" & rhs == "rr", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                      subset(ests_poprr_method, op == "~~" & lhs == "pop" & rhs == "rr", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_poprr$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_poprr_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_poprr_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_poprr <- rbind(load_nomethod, load_method)
loadings_poprr$model <- c(rep("No Method", nrow(load_nomethod)),
                            rep("Method", nrow(load_nomethod)))
loadings_poprr$var <- "poprr"

# store error variance
p <- parameterestimates(m_poprr_method)
m_var_poprr <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# * Populism-HS -------------------------------------------------------------
m <- '
pop =~ pop_fewints
+ pop_crooked
+ pop_nomethink
+ pop_polsimprove # rev here down
+ pop_yesmethink
+ pop_benefitall

hs =~ hs_control
+ hs_exaggerate
+ hs_leash
+ hs_reasonable
+ hs_feministpower
+ hs_fewwomen

# error variances (content similarities)
hs_reasonable ~~ hs_feministpower
pop_nomethink ~~ pop_yesmethink
'
m_pophs <- cfa(m, mt)
summary(m_pophs, fit.measures = T, standardized = T)

m_method <- '
# substantive
pop =~ pop_fewints
+ pop_crooked
+ pop_nomethink
+ pop_polsimprove # rev here down
+ pop_yesmethink
+ pop_benefitall


hs =~ hs_control
+ hs_exaggerate
+ hs_leash
+ hs_reasonable
+ hs_feministpower
+ hs_fewwomen

# method
method =~ pop_fewints
+ 1*pop_crooked
+ 1*pop_nomethink
+ -1*pop_polsimprove # rev here down
+ -1*pop_yesmethink
+ -1*pop_benefitall
+ 1* hs_control
+ 1*hs_exaggerate
+ 1*hs_leash
+ -1*hs_reasonable
+ -1*hs_feministpower
+ -1*hs_fewwomen

# error variances (content similarities)
hs_reasonable ~~ hs_feministpower
pop_nomethink ~~ pop_yesmethink

# covariances
method ~~ 0*pop + 0*hs
'
m_pophs_method <- cfa(m_method, mt)
summary(m_pophs_method, fit.measures = T, standardized = T) 

# residuals(m_pophs_method, type = "standardized")
# modindices(m_pophs_method, minimum.value = 10, sort = T)

# store correlations
ests_pophs_nomethod <- standardizedSolution(m_pophs)
ests_pophs_method <- standardizedSolution(m_pophs_method)
ests_pophs <- rbind(subset(ests_pophs_nomethod, op == "~~" & lhs == "pop" & rhs == "hs", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                      subset(ests_pophs_method, op == "~~" & lhs == "pop" & rhs == "hs", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_pophs$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_pophs_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_pophs_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_pophs <- rbind(load_nomethod, load_method)
loadings_pophs$model <- c(rep("No Method", nrow(load_nomethod)),
                            rep("Method", nrow(load_nomethod)))
loadings_pophs$var <- "pophs"

# store error variance
p <- parameterestimates(m_pophs_method)
m_var_pophs <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# * Violence-Conspiracy -------------------------------------------------------------
m <- '
viol =~ viol_threatpols
+ viol_bricks
+ viol_stopbadgovt
+ viol_bullets
+ viol_noviol # rev here down
+ viol_nonviolprot # NEW
+ viol_violunaccept # NEW
+ viol_notit4tat # NEW

consp =~ consp_plots
+ consp_fewppl
+ consp_dkrun
+ consp_wars
+ consp_schoolexps # NEW, rev here down
+ consp_complex # NEW
+ consp_US # NEW
'
m_conspviol <- cfa(m, mt)
summary(m_conspviol, fit.measures = T, standardized = T)

m_method <- '
# substantive
viol =~ viol_threatpols
+ viol_bricks
+ viol_stopbadgovt
+ viol_bullets
+ viol_noviol # rev here down
+ viol_nonviolprot # NEW
+ viol_violunaccept # NEW
+ viol_notit4tat # NEW

consp =~ consp_plots
+ consp_fewppl
+ consp_dkrun
+ consp_wars
+ consp_schoolexps # NEW, rev here down
+ consp_complex # NEW
+ consp_US # NEW

# method
method =~ consp_plots
+ 1*consp_fewppl
+ 1*consp_dkrun
+ 1*consp_wars
+ -1*consp_schoolexps # NEW, rev here down
+ -1*consp_complex # NEW
+ -1*consp_US # NEW
+ 1*viol_threatpols
+ 1*viol_bricks
+ 1*viol_stopbadgovt
+ 1*viol_bullets
+ -1*viol_noviol # rev here down
+ -1*viol_nonviolprot # NEW
+ -1*viol_violunaccept # NEW
+ -1*viol_notit4tat # NEW

# covariances
method ~~ 0*consp + 0*viol
'
m_conspviol_method <- cfa(m_method, mt)
summary(m_conspviol_method, fit.measures = T, standardized = T) 

# residuals(m_conspviol_method, type = "standardized")
# modindices(m_conspviol_method, minimum.value = 10, sort = T)

# store correlations
ests_conspviol_nomethod <- standardizedSolution(m_conspviol)
ests_conspviol_method <- standardizedSolution(m_conspviol_method)
ests_conspviol <- rbind(subset(ests_conspviol_nomethod, op == "~~" & lhs == "viol" & rhs == "consp", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                      subset(ests_conspviol_method, op == "~~" & lhs == "viol" & rhs == "consp", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_conspviol$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_conspviol_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_conspviol_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_conspviol <- rbind(load_nomethod, load_method)
loadings_conspviol$model <- c(rep("No Method", nrow(load_nomethod)),
                            rep("Method", nrow(load_nomethod)))
loadings_conspviol$var <- "conspviol"

# store error variance
p <- parameterestimates(m_conspviol_method)
m_var_conspviol <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# * Violence-RR -------------------------------------------------------------
m <- '
viol =~ viol_threatpols
+ viol_bricks
+ viol_stopbadgovt
+ viol_bullets
+ viol_noviol # rev here down
+ viol_nonviolprot # NEW
+ viol_violunaccept # NEW
+ viol_notit4tat # NEW

rr =~ rr_specfavr
+ rr_thard
+ rr_pdisc
+ rr_dless

# error variances (content similarities)
rr_thard ~~ rr_specfavr

'
m_rrviol <- cfa(m, mt)
summary(m_rrviol, fit.measures = T, standardized = T)

m_method <- '
# substantive
viol =~ viol_threatpols
+ viol_bricks
+ viol_stopbadgovt
+ viol_bullets
+ viol_noviol # rev here down
+ viol_nonviolprot # NEW
+ viol_violunaccept # NEW
+ viol_notit4tat # NEW

rr =~ rr_specfavr
+ rr_thard
+ rr_pdisc
+ rr_dless

# method
method =~ rr_specfavr
+ 1*rr_thard
+ -1*rr_pdisc
+ -1*rr_dless
+ 1*viol_threatpols
+ 1*viol_bricks
+ 1*viol_stopbadgovt
+ 1*viol_bullets
+ -1*viol_noviol # rev here down
+ -1*viol_nonviolprot # NEW
+ -1*viol_violunaccept # NEW
+ -1*viol_notit4tat # NEW

# error variances (content similarities)
rr_thard ~~ rr_specfavr

# covariances
method ~~ 0*rr + 0*viol
'
m_rrviol_method <- cfa(m_method, mt)
summary(m_rrviol_method, fit.measures = T, standardized = T) 

# residuals(m_rrviol_method, type = "standardized")
# modindices(m_rrviol_method, minimum.value = 10, sort = T)

# store correlations
ests_rrviol_nomethod <- standardizedSolution(m_rrviol)
ests_rrviol_method <- standardizedSolution(m_rrviol_method)
ests_rrviol <- rbind(subset(ests_rrviol_nomethod, op == "~~" & lhs == "viol" & rhs == "rr", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                        subset(ests_rrviol_method, op == "~~" & lhs == "viol" & rhs == "rr", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_rrviol$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_rrviol_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_rrviol_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_rrviol <- rbind(load_nomethod, load_method)
loadings_rrviol$model <- c(rep("No Method", nrow(load_nomethod)),
                              rep("Method", nrow(load_nomethod)))
loadings_rrviol$var <- "rrviol"

# store error variance
p <- parameterestimates(m_rrviol_method)
m_var_rrviol <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# * Violence-HS -------------------------------------------------------------
m <- '
viol =~ viol_threatpols
+ viol_bricks
+ viol_stopbadgovt
+ viol_bullets
+ viol_noviol # rev here down
+ viol_nonviolprot # NEW
+ viol_violunaccept # NEW
+ viol_notit4tat # NEW

hs =~ hs_control
+ hs_exaggerate
+ hs_leash
+ hs_reasonable
+ hs_feministpower
+ hs_fewwomen

# error variances (content similarities)
hs_reasonable ~~ hs_feministpower
'
m_hsviol <- cfa(m, mt)
summary(m_hsviol, fit.measures = T, standardized = T)

m_method <- '
# substantive
viol =~ viol_threatpols
+ viol_bricks
+ viol_stopbadgovt
+ viol_bullets
+ viol_noviol # rev here down
+ viol_nonviolprot # NEW
+ viol_violunaccept # NEW
+ viol_notit4tat # NEW

hs =~ hs_control
+ hs_exaggerate
+ hs_leash
+ hs_reasonable
+ hs_feministpower
+ hs_fewwomen

# method
method =~ hs_control
+ 1*hs_exaggerate
+ 1*hs_leash
+ -1*hs_reasonable
+ -1*hs_feministpower
+ -1*hs_fewwomen
+ 1*viol_threatpols
+ 1*viol_bricks
+ 1*viol_stopbadgovt
+ 1*viol_bullets
+ -1*viol_noviol # rev here down
+ -1*viol_nonviolprot # NEW
+ -1*viol_violunaccept # NEW
+ -1*viol_notit4tat # NEW

# error variances (content similarities)
hs_reasonable ~~ hs_feministpower


# covariances
method ~~ 0*hs + 0*viol
'
m_hsviol_method <- cfa(m_method, mt)
summary(m_hsviol_method, fit.measures = T, standardized = T) 

# residuals(m_hsviol_method, type = "standardized")
# modindices(m_hsviol_method, minimum.value = 10, sort = T)

# store correlations
ests_hsviol_nomethod <- standardizedSolution(m_hsviol)
ests_hsviol_method <- standardizedSolution(m_hsviol_method)
ests_hsviol <- rbind(subset(ests_hsviol_nomethod, op == "~~" & lhs == "viol" & rhs == "hs", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                        subset(ests_hsviol_method, op == "~~" & lhs == "viol" & rhs == "hs", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_hsviol$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_hsviol_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_hsviol_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_hsviol <- rbind(load_nomethod, load_method)
loadings_hsviol$model <- c(rep("No Method", nrow(load_nomethod)),
                              rep("Method", nrow(load_nomethod)))
loadings_hsviol$var <- "hsviol"

# store error variance
p <- parameterestimates(m_hsviol_method)
m_var_hsviol <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# * Conspiracy-RR -------------------------------------------------------------
m <- '
consp =~ consp_plots
+ consp_fewppl
+ consp_dkrun
+ consp_wars
+ consp_schoolexps # NEW, rev here down
+ consp_complex # NEW
+ consp_US # NEW

rr =~ rr_specfavr
+ rr_thard
+ rr_pdisc
+ rr_dless

# error variances (content similarities)
rr_thard ~~ rr_specfavr
'
m_consprr <- cfa(m, mt)
summary(m_consprr, fit.measures = T, standardized = T)

m_method <- '
# substantive
consp =~ consp_plots
+ consp_fewppl
+ consp_dkrun
+ consp_wars
+ consp_schoolexps # NEW, rev here down
+ consp_complex # NEW
+ consp_US # NEW

rr =~ rr_specfavr
+ rr_thard
+ rr_pdisc
+ rr_dless


# method
method =~ consp_plots
+ 1*consp_fewppl
+ 1*consp_dkrun
+ 1*consp_wars
+ -1*consp_schoolexps # NEW, rev here down
+ -1*consp_complex # NEW
+ -1*consp_US # NEW
+ 1*rr_specfavr
+ 1*rr_thard
+ -1*rr_pdisc
+ -1*rr_dless

# error variances (content similarities)
rr_thard ~~ rr_specfavr

# covariances
method ~~ 0*consp + 0*rr
'
m_consprr_method <- cfa(m_method, mt)
summary(m_consprr_method, fit.measures = T, standardized = T) 

# residuals(m_consprr_method, type = "standardized")
# modindices(m_consprr_method, minimum.value = 10, sort = T)

# store correlations
ests_consprr_nomethod <- standardizedSolution(m_consprr)
ests_consprr_method <- standardizedSolution(m_consprr_method)
ests_consprr <- rbind(subset(ests_consprr_nomethod, op == "~~" & lhs == "consp" & rhs == "rr", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                        subset(ests_consprr_method, op == "~~" & lhs == "consp" & rhs == "rr", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_consprr$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_consprr_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_consprr_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_consprr <- rbind(load_nomethod, load_method)
loadings_consprr$model <- c(rep("No Method", nrow(load_nomethod)),
                              rep("Method", nrow(load_nomethod)))
loadings_consprr$var <- "consprr"

# store error variance
p <- parameterestimates(m_consprr_method)
m_var_consprr <- p$est[which(p$lhs == "method" & p$rhs == "method")]



# * Conspiracy-HS -------------------------------------------------------------
m <- '
consp =~ consp_plots
+ consp_fewppl
+ consp_dkrun
+ consp_wars
+ consp_schoolexps # NEW, rev here down
+ consp_complex # NEW
+ consp_US # NEW

hs =~ hs_control
+ hs_exaggerate
+ hs_leash
+ hs_reasonable
+ hs_feministpower
+ hs_fewwomen

# error variances (content similarities)
hs_reasonable ~~ hs_feministpower
'
m_consphs <- cfa(m, mt)
summary(m_consphs, fit.measures = T, standardized = T)

m_method <- '
# substantive
consp =~ consp_plots
+ consp_fewppl
+ consp_dkrun
+ consp_wars
+ consp_schoolexps # NEW, rev here down
+ consp_complex # NEW
+ consp_US # NEW

hs =~ hs_control
+ hs_exaggerate
+ hs_leash
+ hs_reasonable
+ hs_feministpower
+ hs_fewwomen


# method
method =~ consp_plots
+ 1*consp_fewppl
+ 1*consp_dkrun
+ 1*consp_wars
+ -1*consp_schoolexps # NEW, rev here down
+ -1*consp_complex # NEW
+ -1*consp_US # NEW
+ 1*hs_control
+ 1*hs_exaggerate
+ 1*hs_leash
+ -1*hs_reasonable
+ -1*hs_feministpower
+ -1*hs_fewwomen

# error variances (content similarities)
hs_reasonable ~~ hs_feministpower

# covariances
method ~~ 0*consp + 0*hs
'
m_consphs_method <- cfa(m_method, mt)
summary(m_consphs_method, fit.measures = T, standardized = T) 

# residuals(m_consphs_method, type = "standardized")
# modindices(m_consphs_method, minimum.value = 10, sort = T)

# store cohselations
ests_consphs_nomethod <- standardizedSolution(m_consphs)
ests_consphs_method <- standardizedSolution(m_consphs_method)
ests_consphs <- rbind(subset(ests_consphs_nomethod, op == "~~" & lhs == "consp" & rhs == "hs", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                      subset(ests_consphs_method, op == "~~" & lhs == "consp" & rhs == "hs", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_consphs$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_consphs_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_consphs_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_consphs <- rbind(load_nomethod, load_method)
loadings_consphs$model <- c(rep("No Method", nrow(load_nomethod)),
                            rep("Method", nrow(load_nomethod)))
loadings_consphs$var <- "consphs"

# store ehsor variance
p <- parameterestimates(m_consphs_method)
m_var_consphs <- p$est[which(p$lhs == "method" & p$rhs == "method")]



# * RR-HS -------------------------------------------------------------
m <- '
rr =~ rr_specfavr
+ rr_thard
+ rr_pdisc
+ rr_dless

hs =~ hs_control
+ hs_exaggerate
+ hs_leash
+ hs_reasonable
+ hs_feministpower
+ hs_fewwomen

# error variances (content similarities)
hs_reasonable ~~ hs_feministpower
rr_thard ~~ rr_specfavr
'
m_hsrr <- cfa(m, mt)
summary(m_hsrr, fit.measures = T, standardized = T)

m_method <- '
# substantive
rr=~ rr_specfavr
+ rr_thard
+ rr_pdisc
+ rr_dless

hs =~ hs_control
+ hs_exaggerate
+ hs_leash
+ hs_reasonable
+ hs_feministpower
+ hs_fewwomen

# method
method =~ rr_specfavr
+ 1*rr_thard
+ -1*rr_pdisc
+ -1*rr_dless
+ 1*hs_control
+ 1*hs_exaggerate
+ 1*hs_leash
+ -1*hs_reasonable
+ -1*hs_feministpower
+ -1*hs_fewwomen

# error variances (content similarities)
hs_reasonable ~~ hs_feministpower
rr_thard ~~ rr_specfavr

# covariances
method ~~ 0*hs + 0*rr
'
m_hsrr_method <- cfa(m_method, mt)
summary(m_hsrr_method, fit.measures = T, standardized = T) 

# residuals(m_hsrr_method, type = "standardized")
# modindices(m_hsrr_method, minimum.value = 10, sort = T)

# store correlations
ests_hsrr_nomethod <- standardizedSolution(m_hsrr)
ests_hsrr_method <- standardizedSolution(m_hsrr_method)
ests_hsrr <- rbind(subset(ests_hsrr_nomethod, op == "~~" & lhs == "rr" & rhs == "hs", select = c("lhs", "rhs", "est.std", "se", "pvalue")),
                      subset(ests_hsrr_method, op == "~~" & lhs == "rr" & rhs == "hs", select = c("lhs", "rhs", "est.std", "se", "pvalue")))
ests_hsrr$model <- c("No Method", "Method")

# store loadings
load_nomethod <- subset(ests_hsrr_nomethod, op == "=~", select = c("lhs", "rhs", "est.std", "se"))
load_method <- subset(ests_hsrr_method, op == "=~" & lhs != "method", select = c("lhs", "rhs", "est.std", "se"))
loadings_hsrr <- rbind(load_nomethod, load_method)
loadings_hsrr$model <- c(rep("No Method", nrow(load_nomethod)),
                            rep("Method", nrow(load_nomethod)))
loadings_hsrr$var <- "hsrr"

# store error variance
p <- parameterestimates(m_hsrr_method)
m_var_hsrr <- p$est[which(p$lhs == "method" & p$rhs == "method")]


# Combine -----------------------------------------------------------------
# correlations
ests <- rbind(ests_consphs, ests_consprr, ests_conspviol, ests_hsrr, ests_hsviol, ests_nfcconsp, 
              ests_nfchs, ests_nfcPop, ests_nfcrr, ests_nfcviol, ests_popconsp, ests_pophs, 
              ests_poprr, ests_popviol, ests_rrviol)
# method variance
error_vars <- c(m_var_consphs, m_var_consprr, m_var_conspviol, m_var_hsrr, m_var_hsviol,
                m_var_nfcconsp, m_var_nfchs, m_var_nfcPop, m_var_nfcrr, m_var_nfcviol, 
                m_var_popconsp, m_var_pophs, m_var_poprr, m_var_popviol, m_var_rrviol)
x <- paste("", round(error_vars, 3))

ests_wide_s3 <- reshape(ests, idvar = c("lhs", "rhs"), timevar = "model", direction = "wide")
ests_wide_s3$study <- "Study 3"

# combine
# ests$lhs <- c("Anti-Democratic Attitudes (PW)", "Anti-Democratic Attitudes (PW)",
#               "Anti-Democratic Attitudes (PW)", "Anti-Democratic Attitudes (PW)",
#               "Populism (B)", "Populism (B)",
#               "Populism (B)", "Populism (B)",
#               "Populism (B)", "Populism (B)",
#               "Conspiracy (PW)", "Conspiracy (PW)")
# ests$rhs <- c("Conspiracy (PW)", "Conspiracy (PW)", 
#               "Hostile Sexism (B)", "Hostile Sexism (B)",
#               "Anti-Democratic Attitudes (PW)", "Anti-Democratic Attitudes (PW)", 
#               "Conspiracy (PW)", "Conspiracy (PW)",
#               "Hostile Sexism (B)", "Hostile Sexism (B)",
#               "Hostile Sexism (B)", "Hostile Sexism (B)")
ests$method_variance <- unlist(strsplit(x, " "))
names(ests) <- c("Var1", "Correlation", "SE", "p_value", "Model", "Var2", "Method Variance")
ests$corr <- paste(ests$Var1, ests$Var2, sep = " with ")
ests_2F <- subset(ests, select = c("corr",  "Correlation", "SE", "p_value", "Model", "Method Variance"))
# write.csv(ests, file = "dynata_measurementModel.csv", row.names = FALSE)


# y <- c(((0.748-0.803)/0.803),((.603-0.668)/0.668),((0.299-0.060)/0.060),((0.530-0.289)/0.289),((0.092--0.090)/-0.090), ((0.529-0.606)/0.606))

